<template>
	<view>
		<view>
			<uni-search-bar @confirm="search" :focus="true" v-model="searchValue" @blur="blur" @input="input" @cancel="cancel" @change="change" @clear="clear">
			</uni-search-bar>
			当前输入为：{{ searchValue }}
		</view>
		
		<view class="list" >
			<uni-list v-for="(item ,index) in lists" :key="index" >
				<uni-list-item showArrow :title="item.title" 
				 clickable  @click="onClick()">
				 </uni-list-item>
			</uni-list>
			<!-- <uni-load-more :status="status" :icon-size="14" :content-text="contentText"  /> -->
		</view>
		
		<view>
			
			
			
		</view>
		
	</view>
</template>

<script>
import {loginRequest} from '@/api/request.js'
//import chatRoom from '/pages/chatRoom/chatRoom.vue';

	export default {
		// components: {
		//      chatRoom
		//  },

		data() {
			return {
				searchValue: '123123',
				lists: [],
				status: 'more',

				contentText: {
					contentdown: '加载更多~',
					contentrefresh: '加载中',
					contentnomore: '我是有底线的~'
				},
			}
		},
		methods: {
			search(res) {
				uni.showToast({
					title: '搜索：' + res.value,
					icon: 'none'
				})
			},
			input(res) {
				console.log('----input:', res)
			},
			clear(res) {
				uni.showToast({
					title: 'clear事件，输入值为：' + res.value,
					icon: 'none'
				})
			},
			blur(res) {
				uni.showToast({
					title: 'blur事件，输入值为：' + res.value,
					icon: 'none'
				})
			},
			cancel(res) {
				uni.showToast({
					title: '点击取消，输入值为：' + res.value,
					icon: 'none'
				})
			},
			
			change(res){
				
			},

			onClick(item) {
			  //跳转到chatRoom页面
			  uni.navigateTo({
										url: '/pages/chatRoom/chatRoom'
									})

			},

			async getList() {
			    let doctorId=350;
				// this.isloading = true
				// uni.showLoading({
				// 	title: '加载中'
				// });
				try{
				uni.request({
					url: loginRequest.baseURL + 'chatGroup/queryChatGroupsByDoctorId?doctorId='+doctorId,
					method: 'GET',
					success: res => {
						if (res.data.code === 200) {
							this.lists = res.data.data;
							console.log("---------------")
							console.log(this.lists)
						} else {
							uni.showToast({
								title: res.data.msg,
								icon: "error"
							})
						}
			
					}
				}) 
				 	} catch (error) {
				 				console.error('请求失败：', error);
				 				uni.showToast({
				 					title: '请求失败，请稍后再试',
				 					icon: "error"
				 				});
				 				this.status = 'more'; // 恢复为可加载更多状态
				 			} finally {
				 				this.status = 'more'; // 确保最终状态为可加载更多（除非已经没有更多数据）
				 			}
				// uni.hideLoading()
				// this.isloading = false
			},
		},
		mounted() {
				this.getList(); // 页面加载时获取第一页数据
			}
	}
</script>

<style>

</style>
